/**
 * @Author: boyyang
 * @Date: 2022-02-03 11:20:25
 * @LastEditTime: 2022-02-03 11:59:36
 * @LastEditors: boyyang
 * @Description: 
 * @FilePath: \boyyang\functions\usersSig\index.js
 */

const cloudbase = require("@cloudbase/node-sdk")
const TLSSigAPIv2 = require('tls-sig-api-v2')
// const TLSSigAPIv2 = require('./TLSSigAPIv2'); // 源码集成需要使用相对路径

const app = cloudbase.init({
    env: 'boyyang-8gv2s8f21447c0c6'
})

const db = app.database()
const _ = db.command
//  exports.Api = Api;
exports.main = async (event, context) => {
    const { userId, appId, secretKey } = event
    const api = new TLSSigAPIv2.Api(appId, secretKey)
    const sig = api.genSig(userId, 86400 * 180)
    
    return {
        sig
    }
}

